package b2datastructure.graph;

import lombok.Data;

/**
 * @date 2022/3/3 9:21
 * 图的边
 */
@Data
public class Edge {
    private String unique;
    private Integer vertixStart;
    private Integer vertixEnd;
    private Integer weight;

    public Edge(Integer vertixStart, Integer vertixEnd, Integer weight) {
        if(vertixStart.intValue()<vertixEnd.intValue()){
            this.unique = vertixStart+"to"+vertixEnd;
        }else{
            this.unique = vertixEnd+"to"+vertixStart;
        }

        this.vertixStart = vertixStart;
        this.vertixEnd = vertixEnd;
        this.weight = weight;
    }
    public String getUnique(){
        if(vertixStart.intValue()<vertixEnd.intValue()){
            return vertixStart+"to"+vertixEnd;
        }else{
            return vertixEnd+"to"+vertixStart;
        }
    }
    public Integer getOtherVertix(Integer current){
        if(!vertixStart.equals(current)){
            return vertixEnd;
        }else{
            return vertixStart;
        }
    }
}
